import Vue from 'vue'
import App from './App.vue'
import router from './router.js'
import qs from 'qs'
import axios from 'axios'
require('./assets/css/common.less')
import FastClick from './assets/js/fastclick.js'
FastClick.attach(document.body)
// Rem布局方式 100px = 1rem
;(function (doc, win) {
  var docEl = doc.documentElement,
    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
    recalc = function () {
      var clientWidth = docEl.clientWidth
      if (!clientWidth) return
      if (clientWidth >= 750) {
        docEl.style.fontSize = '100px'
      } else {
        docEl.style.fontSize = 100 * (clientWidth / 750) + 'px'
      }
  }
  if (!doc.addEventListener) return
  win.addEventListener(resizeEvt, recalc, false)
  doc.addEventListener('DOMContentLoaded', recalc, false)
  })(document, window)
  Vue.prototype.$ajax = axios
  Vue.prototype.$qs = qs
  Vue.prototype.$ms = new Vue()
  Vue.filter('fixed', function (value) {
  if (value < 0) {
    value = 0
  }
  return (value - 0).toFixed(0)
})
Vue.filter('toFixed', function (value) {
  if (value < 0) {
    value = 0
  }
  return (value - 0).toFixed(2)
})
Vue.filter('day', function (value) {
  if (value == 1) {
    value = ''
  }
  return value
})
Vue.filter('showDay', function (value) {
  if (!isNaN(Number(value))) {
    var date = new Date(value)
    var y = date.getFullYear()
    var m = date.getMonth() + 1
    m = m < 10 ? '0' + m : m
    var d = date.getDate()
    d = d < 10 ? '0' + d : d
    var h = date.getHours()
    h = h < 10 ? '0' + h : h
    return y + '/' + m + '/' + d + ' ' + h + '时'
  }else {
    return value
  }
})

new Vue({
  el: '#app',
  router,
  render: h => h(App)
})
